﻿using System;
using System.Collections;
using ParticlePlayground;

namespace UnityEngine
{
	// Token: 0x020000F9 RID: 249
	public class PlaygroundRecordingExample : MonoBehaviour
	{
		// Token: 0x06000578 RID: 1400 RVA: 0x00021E64 File Offset: 0x00020064
		public virtual IEnumerator Start()
		{
			this.guiArea = new Rect(10f, 10f, (float)Screen.width * 0.5f, 130f);
			if (this.recordFromStart)
			{
				while (!this.playgroundRecorder.playgroundSystem.IsReady())
				{
					yield return null;
				}
				this.playgroundRecorder.StartRecording(this.keyframeInterval);
			}
			yield break;
		}

		// Token: 0x06000579 RID: 1401 RVA: 0x00021E80 File Offset: 0x00020080
		public virtual void Update()
		{
			if (this.hoveringScrubSlider && Input.GetMouseButton(0))
			{
				this.isScrubbing = true;
			}
			else if (Input.GetMouseButtonUp(0))
			{
				this.isScrubbing = false;
			}
			if (this.isScrubbing)
			{
				this.playgroundRecorder.Scrub(this.playbackSliderValue);
			}
		}

		// Token: 0x0600057A RID: 1402 RVA: 0x00021EE0 File Offset: 0x000200E0
		public virtual void OnGUI()
		{
			GUILayout.BeginArea(this.guiArea, "Playground Recorder");
			GUILayout.Space(18f);
			GUILayout.BeginHorizontal(new GUILayoutOption[0]);
			if (GUILayout.Button(this.playgroundRecorder.IsRecording() ? "Stop Recording" : "Record", new GUILayoutOption[0]))
			{
				if (!this.playgroundRecorder.IsRecording())
				{
					this.playgroundRecorder.StartRecording(this.keyframeInterval);
				}
				else
				{
					this.playgroundRecorder.StopRecording();
				}
			}
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal(new GUILayoutOption[0]);
			GUILayout.Label("Time (" + ((float)this.playgroundRecorder.FrameCount() * this.keyframeInterval * this.playbackSliderValue).ToString("F1") + ")", new GUILayoutOption[]
			{
				GUILayout.MaxWidth(40f)
			});
			this.playbackSliderValue = GUILayout.HorizontalSlider(this.playbackSliderValue, 0f, 1f, new GUILayoutOption[0]);
			if (this.playgroundRecorder.IsRecording())
			{
				this.playbackSliderValue = 1f;
			}
			this.hoveringScrubSlider = (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition));
			GUILayout.EndHorizontal();
			GUILayout.EndArea();
		}

		// Token: 0x04000592 RID: 1426
		public ParticlePlayground.PlaygroundRecorder playgroundRecorder;

		// Token: 0x04000593 RID: 1427
		public float keyframeInterval = 0.1f;

		// Token: 0x04000594 RID: 1428
		public bool recordFromStart = true;

		// Token: 0x04000595 RID: 1429
		public Rect guiArea;

		// Token: 0x04000596 RID: 1430
		public bool hoveringScrubSlider;

		// Token: 0x04000597 RID: 1431
		public bool isScrubbing;

		// Token: 0x04000598 RID: 1432
		public float playbackSliderValue;
	}
}
